<extend name="Layout/ins_page" />
<block name="content">
    <link href="/sap/demo.css" rel="stylesheet" type="text/css" />
    <script src="/sap/scripts/boot.js" type="text/javascript"></script>
    <style>
        table img{width: 40px}
    </style>
    <body style="">
    <div class='show-pic'><img /></div>
    <div id="form1" >

        <span class='span'>用户ID : </span>  <input type="input" class='mini-textbox' id='key' name='key' style="width: 180px"/>
        <a class="mini-button" iconCls="icon-search" onclick="search()" style="margin-left: -9px"></a>
        <br><br>

        <div id="grid1" class="mini-datagrid" style="width:100%;height:500px;"
             url="Report/getloginlogdata" idField="id"
             allowResize="true" pageSize="50"
             allowCellEdit="true" allowCellSelect="true" multiSelect="true"
             editNextOnEnterKey="true">
            <div property="columns">
                <div header="用户ID" field="emp_no" width="80px">
                    <input id="emp_no" property="filter" class="mini-textbox" style="width:100%;" onvaluechanged="onFilterChanged"/>
                </div>
                <div header="IP地址" field="ip"  width="80px">
                    <input id="ip" class="mini-textbox" style="width:100%;" onvaluechanged="onFilterChanged"/>
                </div>
                <div header="浏览器" field="http_user_agent"  width="200px">
                    <input id="http_user_agent" class="mini-textbox" style="width:100%;" onvaluechanged="onFilterChanged"/>
                </div>
                <div header="是否成功" field="login_true"  width="50px">
                    <input id="login_true" property="filter" class="mini-textbox" style="width:100%;" onvaluechanged="onFilterChanged"/>
                </div>
                <div header="时间" field="time"  width="200px">
                    <input id="time" property="filter" class="mini-textbox" style="width:100%;" onvaluechanged="onFilterChanged"/>
                </div>

            </div>
        </div>

    </div>

    </body>
</block>
<block name="js">
    <script type="text/javascript">
        mini.parse();
        var grid1 = mini.get("grid1");
        function search(){
            var key = mini.get('key').getValue();
            grid1.load({'key':key});
        }

        //绘制表格
        grid1.on("drawcell", function (e) {

            var record = e.record,
                column = e.column,
                field = e.field,
                value = e.value;

            if (field == "login_true" ) {
                e.cellHtml = value == 1 ? "成功" : "失败";
            }

            //格式化日期
            if (field == "time" ) {
                if (mini.isDate(value)) e.cellHtml = mini.formatDate(value, "yyyy-MM-dd HH:mm:ss");
            }

        });

    </script>
</block>